<?php
class CompleteBookInfo extends Zend_Form {
	
	private $book;
	
	public function CompleteBookInfo($book) {
		$this->book = $book;
		$this->__construct();
	}
	
	public function init() {
		$this->setMethod("POST");
		$this->setName("CompleteBookInfo");
		
		$element = new Zend_Form_Element_Hidden(Book::ID);
		$element->setValue($this->book->id);
		$this->addElement($element);
		
		$element = new Zend_Form_Element_Hidden(Book::ASIN);
        $element->setValue($this->book->ASIN);
        $element->removeDecorator('Label');
        $this->addElement($element);
        
        $element = new Zend_Form_Element_Select(Book::SOURCE);
        $element->setLabel("Book Source");
        $element->addMultiOption("0", "Select book source");
        $element->addMultiOptions(array(BookSource::AMAZON=>BookSource::AMAZON, BookSource::MANUAL=>BookSource::MANUAL));
        $element->setValue($this->book->source);
        $this->addElement($element);
        
        $element = new Zend_Form_Element_Text(Book::DETAIL_PAGE_URL);
        $element->setValue($this->book->detail_page_url);
        $element->setLabel("Detail Page URL");
        $this->addElement($element);
        
        $element = new Zend_Form_Element_Text(Book::NAME);
        $element->setValue($this->book->name);
        $element->setLabel("Title");
        $this->addElement($element);
        
        $element = new Zend_Form_Element_Textarea(Book::DESCRIPTION);
        $element->setValue($this->book->description);
        $element->setAttrib("class", "mceEditor");
        $element->setLabel("Description");
        $this->addElement($element);
        
        $element = new Zend_Form_Element_Text(Book::ISBN);
        $element->setValue($this->book->ISBN);
        $element->setLabel("ISBN");
        $this->addElement($element);
        
        $element = new Zend_Form_Element_Text(Book::ISBN13);
        $element->setValue($this->book->ISBN13);
        $element->setLabel("ISBN13");
        $this->addElement($element);
        
        $element = new Zend_Form_Element_Text(Book::SMALL_IMAGE);
        $element->setValue($this->book->small_image);
        $element->setLabel("Small Image");
        $this->addElement($element);
        
        $element = new Zend_Form_Element_Text(Book::MEDIUM_IMAGE);
        $element->setValue($this->book->medium_image);
        $element->setLabel("Medium Image");
        $this->addElement($element);
        
        $element = new Zend_Form_Element_Text(Book::LARGE_IMAGE);
        $element->setValue($this->book->large_image);
        $element->setLabel("Large Image");
        $this->addElement($element);
        
        $element = new Zend_Form_Element_Select(Book::CURRENCY);
        $element->setValue($this->book->currency);
        $element->setLabel("Currency");
        $element->addMultiOption("0", "Select Currency");
        $element->addMultiOptions(Currency::getCurrencyAsArray());
        $this->addElement($element);
        
        $element = new Zend_Form_Element_Hidden(Book::AMOUNT);
        $element->setValue($this->book->amount);
        $element->removeDecorator('Label');
        $this->addElement($element);
        
        $element = new Zend_Form_Element_Text(Book::AUTHOR);
        $element->setValue($this->book->author);
        $element->setLabel("Author");
        $this->addElement($element);
        
        $element = new Zend_Form_Element_Hidden(Book::BINDING);
        $element->setValue($this->book->binding);
        $element->removeDecorator('Label');
        $this->addElement($element);
        
        $element = new Zend_Form_Element_Text(Book::MANUFACTURER);
        $element->setValue($this->book->manufacturer);
        $element->setLabel("Manufacturer");
        $this->addElement($element);
        
        $element = new Zend_Form_Element_Text(Book::NUM_OF_PAGES);
        $element->setValue($this->book->number_of_pages);
        $element->setLabel("Number of pages");
        $this->addElement($element);
        
        $element = new Zend_Form_Element_Text(Book::PUBLICATION_DATE);
        $element->setValue($this->book->publication_date);
        $element->setLabel("Publication Date");
        $this->addElement($element);
        
        $element = new Zend_Form_Element_Text(Book::PUBLISHER);
        $element->setLabel("Publisher");
        $element->setValue($this->book->publisher);
        $this->addElement($element);
        
        $element = new Zend_Form_Element_Submit("save");
        $element->setLabel("save");
        $element->removeDecorator('Label');
        $this->addElement($element);
	}
}
?>